home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / brailler-04b-c / brlr ƒ / Shell ƒ / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  2.0 KB  |  62 lines  |  [TEXT/MMCC]

  1. #include "error.h"
  2. #include "main.h"
  3. #include "dialogs.h"
  4. #include "environment.h"
  5. #include "window layer.h"
  6.  
  7. NMRec            gMyNotification;
  8. enum ErrorTypes    gPendingResultCode;
  9.  
  10. void FailNilUPP(UniversalProcPtr theUPP)
  11. {
  12.     if (theUPP == nil)
  13.         HandleError(kNoMemory, FALSE);
  14. }
  15.  
  16. void HandleError(enum ErrorTypes resultCode, Boolean exitToShell)
  17. /* if we're in the foreground, just get the error string (from the .rsrc file) and
  18.    display the error alert; otherwise, we have to queue it, put up a notification
  19.    (if possible), and wait patiently to come back in the foreground.  (see main.c,
  20.    DispatchEvents(), case osEvt. */
  21. /* All error codes are listed in program globals.h */
  22. {
  23.     Str255            tempStr;
  24.     Handle            myResHand;
  25.     
  26.     /* if there is no error, or the error is that the user cancelled an operation
  27.        in progress, don't display anything; it would only confuse them. */
  28.     if ((resultCode==userCancelErr) || (resultCode==allsWell)) return;
  29.     
  30.     if (gIsInBackground)    /* if program is in background, can't display alert immed. */
  31.     {
  32.         if (gHasNotificationManager)    /* if they don't have notification, f*ck 'em */
  33.         {
  34.             myResHand=GetResource('SICN', 1234);    /* small icon for menu bar flashing */
  35.             gMyNotification.qType=nmType;            /* for more detail on these params, */
  36.             gMyNotification.nmMark=1;                /* see IM Processes, 5-8 */
  37.             gMyNotification.nmIcon=myResHand;
  38.             gMyNotification.nmSound=(Handle)-1L;
  39.             gMyNotification.nmStr=0L;
  40.             gMyNotification.nmResp=0L;
  41.             gMyNotification.nmRefCon=0L;
  42.             NMInstall(&gMyNotification);
  43.         }
  44.         gPendingResultCode=resultCode;                /* remember error code for later */
  45.     }
  46.     else
  47.     {
  48.         RemoveHilitePatch();
  49.         GetIndString(tempStr, 129, resultCode);    /* get error string from .rsrc */
  50.         ParamText(tempStr, "\p", "\p", "\p");
  51.         PositionDialog('ALRT', largeAlert);        /* position alert (see dialogs.c) */
  52.         StopAlert(largeAlert, 0L);                /* show it */
  53.         InstallHilitePatch();
  54.     }
  55.     
  56.     if (exitToShell)        /* for fatal errors */
  57.     {
  58.         ShutDownEnvironment(FALSE);
  59.         ExitToShell();
  60.     }
  61. }
  62.